import cv2
import numpy as np

# 读取图片
img = cv2.imread('card.png', 0)

#
kernel = np.ones((2, 2), np.uint8)

eroded = cv2.erode(img, kernel)
#
dilation = cv2.dilate(eroded, kernel)

# 显示结果
cv2.imshow('Original', img)
cv2.imshow('1', eroded)
cv2.imshow('2', dilation)
cv2.waitKey(0)
cv2.destroyAllWindows()
